Query not returning rows in a table that don't have corresponding values in another [associative] ta
Posted
by Obay
on Stack Overflow
See other posts from Stack Overflow
or by Obay
Published on 2010-03-17T21:35:08Z
Indexed on
2010/03/17
21:41 UTC
Read the original article
Hit count: 376
I have
Table: ARTICLES
ID | CONTENT
---------------
1 | the quick
2 | brown fox
3 | jumps over
4 | the lazy
Table: WRITERS
ID | NAME
----------
1 | paul
2 | mike
3 | andy
Table: ARTICLES_TO_WRITERS
ARTICLE_ID | WRITER_ID
-----------------------
1 | 1
2 | 2
3 | 3
To summarize, article 4 has no writer.
So when I do a "search" for articles with the word "the":
SELECT a.id, a.content, w.name
FROM articles a, writers w, articles_to_writers atw
WHERE a.id=atw.article_id AND w.id=atw.writer_id AND content LIKE '%the%'
article 4 does not show up in the result:
ID | CONTENT | NAME
-----------------------
1 | the quick | paul
How do I make article 4 still appear in the results even though it has no writers?
© Stack Overflow or respective owner